package com.github.laozhaishaozuo.asm;

/**
* @author zhangshimin
* @date 2018/11/26
*/
public class UserGetter implements Getter {

	public static Object call(Object bean, String attrName) {
		int hash = attrName.hashCode();
		User user = (User) bean;
		switch (hash) {
			case 1:
				return user.getName();
			case 2:
				return user.getAddress();
			case 3:
				return user.getNumbers();
			case 4:
				return user.getBirthDate();
			default:
				return null;
		}
	}

	public static Object callByName(Object bean, String attrName) {
		User user = (User) bean;
		switch (attrName) {
			case "name":
				return user.getName();
			case "address":
				return user.getAddress();
			case "numbers":
				return user.getNumbers();
			case "birthDate":
				return user.getBirthDate();
			default:
				return null;
		}
	}
}
